# 3  编写一个装饰器，为多个函数加上认证的功能（必须输入用户的账号密码，才能调用这个函数）

login_flag = False

def login_verify(fn):
    def inner(*args, **kwargs):
        global login_flag
        if not login_flag:
            print("please log in")
            while True:
                username = input('username:')
                password = input('password:')
                if username == 'admin' and password == '123456':
                    print('login successfully!')
                    login_flag = True
                    break
                else:
                    print('incorrect username or password!')
        ret = fn(*args, **kwargs)
        return ret
    return inner

@login_verify
def func1():
    print('func1')
def func2():
    print('func2')
def func3():
    print('func3')
def func4():
    print('func4')


func1()
func2()
func3()
func4()



